Digital cameras generally adapt a Charge-Coupled Device (CCD) or Complementary Metal Oxide Semiconductor (CMOS) as a sensor. These sensors may have some defective pixels, including bright pixels and dark pixels, attributed to production issues. These defective pixels are pixels having an abnormal photosensitivity, and are not controllable by the photosensitive system. The dark pixels cannot sense lights, and the bright pixels always output high intensity values. If the pixel values of these defective pixels are not compensated for, image quality would be affected by pixels that should not have existed in the captured scene in the photo. In testing the digital cameras at the factory or self-testing, the coordinates of these defective pixels are measured and recorded, and are stored in a Random Access Memory (RAM) or Read Only Memory (ROM) for storing defect correction data. In actual shooting of images, the digital camera will correct the pixel value of the defective pixel in real time to compensate for the defective pixel, usually by calculating a corrected pixel value of the defective pixel based on the pixel values of pixels in the neighborhood of the defective pixel.
Since neighboring pixels generally have similar pixel values to the defective pixel, an average pixel value of the pixels surrounding the defective pixel is generally used as the corrected pixel value of the defective pixel. Referring to FIG. 1, a typical RGB Bayer sensor uses an average pixel value of the neighboring pixels of the defective pixel in a given color channel as the corrected pixel value of the defective pixel. Take R channel as an example. The position of a defective pixel R22 has been marked, and an average pixel value of eight pixels nearest to the defective pixel R22 is calculated as the corrected pixel value {circumflex over (R)}22:
            R      ^        22    =            1      8        ⁢                  ∑                                                                                                  i                    =                    1                                    ,                  2                  ,                  3                                ⁢                                                                                                                                                                                j                    =                    1                                    ,                  2                  ,                  3                                ⁢                                                                                                                                                            (                                      i                    ,                    j                                    )                                ≠                                  (                                      2                    ,                    2                                    )                                                                        ⁢                        R                      i            ,            j                          .            
When the signal-to-noise ratio (SNR) is relatively low, the area of the neighborhood can be enlarged appropriately to obtain a higher gain from binning. However, if the imaging information of the defective pixel corresponds to an edge of the digital image, detail information of the digital image may be lost. Referring to FIG. 2, the R channel is considered. R22 corresponds to the position of a defective pixel, R13, R22, and R31 correspond to details at the edge of the digital image (color A), and the remaining pixels correspond to color B. Because the number of the pixels corresponding to the color B is greater than the number of the pixels corresponding to the color A, the corrected pixel value {circumflex over (R)}22 of the defective pixel R22 will have the color B to result in a visual discontinuity at the edge. Thus, the neighboring pixels should be weighted differently to result in the corrected pixel value of the defective pixel.
In sum, there is a flaw in the existing averaging method because the method does not effectively distinguish the neighboring pixels of the defective pixel. It is proposed that an improved method of correcting the defective pixel is needed to fully consider the different influences of the pixels in the neighborhood on the defective pixel.